package com.pi.shisan.service.util;

public class DateUtil {

    public static boolean checkDay (Integer year, Integer month, Integer day) {
        if (day == null) {
            return true;
        }
        if (day < 1 || day > 31) {
            return false;
        }
        if (month != null && month >= 1 && month <= 12) {
            switch (month) {
                case 4: case 6: case 9: case 11:
                    return day < 31;
                case 2:
                    //year % 4 == 0 && year % 100 != 0   ||   year % 400 == 0
                    if (year != null && (year % 4 > 0 || (year % 100 == 0 && year % 400 != 0))) {
                        return day < 29;
                    }
                    return day < 30;
            }
        }
        return true;
    }

}
